<?php if(!defined('DB_NAME')) die();
if (!empty($post->post_password)) {
	if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) {
		?>
		<p class="nocomments">必须输入密码，才能查看评论！</p>
		<?php
		return;
	}
}
?>

<div id="comments">
<h2 id="comment-title"><?php
$comment_count = $post->comment_count;
if( get('ini_cmt_h')!="" ){
	$output = get('ini_cmt_h');
	if( ereg('%s',$output) ) $output = str_replace('%s',$comment_count,$output);
	echo $output;
}
else {
	echo "已有{$comment_count}条评论，欢迎点评！";
}
?></h2>
<div id="respond">
<?php cancel_comment_reply_link('点击取消回复')?>
<?php if ( get('comment_registration') && !$user_ID ) : ?>
	<p><?php print '您必须'?><a href="javascript:;" onclick="$('#login-overlay').show() && $('#login-form').fadeIn(400)"> [ 登录 ] </a>才能发表留言！</p>
<?php else : ?>
	<form id="commentform" class="clear" action="<?php echo get('siteurl')?>/wp-comments-post.php" method="post">
<?php if ( $user_ID ) : ?>
		<span><?php print '登录者：'?> <a href="<?php echo get('siteurl')?>/wp-admin/profile.php"><?php echo $user_identity?></a>&nbsp;&nbsp;<a href="<?php echo wp_logout_url(get_permalink())?>"><?php print '[ 退出 ]'?></a></span>
<?php elseif ( '' !=$comment_author ): ?>
		<div class="author"><?php printf(__('欢迎回来 <strong>%s</strong>'), $comment_author)?>
			<a href="javascript:toggleAuthor();" id="toggle-author">[ 更改 ]</a>
		</div>
		<script type="text/javascript" charset="utf-8">
			var changeMsg = "[ 更改 ]";
			var closeMsg = "[ 隐藏 ]";
			function toggleAuthor() {
				jQuery('#commenttext').slideToggle('fast', function(){
					if ( jQuery('#commenttext').css('display') == 'none' ) {
					jQuery('#toggle-author').text(changeMsg);
					} else {
					jQuery('#toggle-author').text(closeMsg);
					}
				});
			}
			jQuery(document).ready(function(){
				jQuery('#commenttext').hide();
			});
		</script>
<?php endif?>
<?php if ( !$user_ID ): ?>
		<div id="commenttext">
			<input type="text" name="author" value="<?php echo $comment_author?>" placeholder="昵称<?php if($req) echo " (必填)"?>" size="24" tabindex="1" />
			<input type="text" name="email" value="<?php echo $comment_author_email?>" placeholder="邮箱<?php if($req) echo " (必填)"?>" size="24" tabindex="2" />
			<input type="text" name="url" value="<?php echo $comment_author_url?>" placeholder="网址" size="24" tabindex="3" />
		</div>
<?php endif?>
		<textarea name="comment" id="comment" tabindex="4"></textarea>
		<div id="editor" class="bd">
			<a href="javascript:;" id="comment-smiley">表情</a>
<?php if( get('ini_editor') && !ismobile() ):?>
			<a href="javascript:;" id="font-color">颜色</a>
			<a href="javascript:SIMPALED.Editor.strong()">粗体</a>
			<a href="javascript:SIMPALED.Editor.em()">斜体</a>
			<a href="javascript:SIMPALED.Editor.ahref()">链接</a>
			<a href="javascript:SIMPALED.Editor.img()">图片</a>
<?php endif?>
			<a href="javascript:SIMPALED.Editor.code()">代码</a>
			<a href="javascript:SIMPALED.Editor.private()">悄悄话</a>
<?php if( !ismobile() ):?>
			<a href="javascript:SIMPALED.Editor.clear()">清空</a>
<?php endif?>
			<input id="submit" name="submit" type="submit" id="submit" tabindex="5" value="发布<?php if(!ismobile()) echo " (Ctrl+Enter)"?>" />
<?php comment_id_fields()?>
		</div>
<?php if( get('ini_editor') && !ismobile() ):?>
		<div id="fontcolor" class="hide">
			<a href="javascript:SIMPALED.Editor.c1()" style="background:red"></a>
			<a href="javascript:SIMPALED.Editor.c2()" style="background:#EE0"></a>
			<a href="javascript:SIMPALED.Editor.c3()" style="background:#46CF7F"></a>
			<a href="javascript:SIMPALED.Editor.c4()" style="background:#7393F8"></a>
			<a href="javascript:SIMPALED.Editor.c5()" style="background:#C0F"></a>
			<a href="javascript:SIMPALED.Editor.c6()" style="background:orange"></a>
			<a href="javascript:SIMPALED.Editor.c7()" style="background:#E9E"></a>
			<a href="javascript:SIMPALED.Editor.c8()" style="background:#F64"></a>
			<a href="javascript:SIMPALED.Editor.c9()" style="background:#FF1493"></a>
			<a href="javascript:SIMPALED.Editor.c10()" style="background:brown"></a>
			<a href="javascript:SIMPALED.Editor.c11()" style="background:#060"></a>
			<a href="javascript:SIMPALED.Editor.c12()" style="background:#09B"></a>
		</div>
<?php endif?>
<?php $sm = '"><img alt="smiley" src="'.TPDIR.'/res/smiley/'?>
		<div id="smiley" class="hide">
			<a href="javascript:grin(':01:')<?php echo $sm?>01.gif"></a>
			<a href="javascript:grin(':02:')<?php echo $sm?>02.gif"></a>
			<a href="javascript:grin(':03:')<?php echo $sm?>03.gif"></a>
			<a href="javascript:grin(':04:')<?php echo $sm?>04.gif"></a>
			<a href="javascript:grin(':05:')<?php echo $sm?>05.gif"></a>
			<a href="javascript:grin(':06:')<?php echo $sm?>06.gif"></a>
			<a href="javascript:grin(':07:')<?php echo $sm?>07.gif"></a>
			<a href="javascript:grin(':08:')<?php echo $sm?>08.gif"></a>
			<a href="javascript:grin(':09:')<?php echo $sm?>09.gif"></a>
			<a href="javascript:grin(':10:')<?php echo $sm?>10.gif"></a>
			<a href="javascript:grin(':11:')<?php echo $sm?>11.gif"></a>
			<a href="javascript:grin(':12:')<?php echo $sm?>12.gif"></a>
			<a href="javascript:grin(':13:')<?php echo $sm?>13.gif"></a>
			<a href="javascript:grin(':14:')<?php echo $sm?>14.gif"></a>
			<a href="javascript:grin(':15:')<?php echo $sm?>15.gif"></a>
			<a href="javascript:grin(':16:')<?php echo $sm?>16.gif"></a>
		</div>
<?php do_action('comment_form', $post->ID)?>
	</form>
<?php endif?>
</div><?php#end respond?>

<?php if( get('ini_ad5')&&( !ismobile() || ismobile()&&get('ini_mad') ) ) echo "	<div class=\"ad5\">".get('ini_ad5_code')."</div>\n"?>
<?php if( $comments ):?>
<div id="comment-loading"></div>
<ol class="comment-list">
<?php $num = get('ini_cmt_num')? get('ini_cmt_num'): 6?>
<?php wp_list_comments('type=comment&callback=ini_comment&end-callback=ini_end_comment&max_depth='.$num)?>
</ol>
<div class="pagination"><?php paginate_comments_links('prev_text=<&next_text=>')?></div>
<?php else: ?>
<p style="font-size:16px"><?php get('ini_cmtinfo') ? print get('ini_cmtinfo') : print '国际惯例, 沙发拿下 . . .'?></p>
<?php endif?>
</div>